﻿<phone:PhoneApplicationPage 
    x:Class="VisualStudioAchievements.UserDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False"
    xmlns:local="clr-namespace:VisualStudioAchievements">
    
    <Grid DataContext="{Binding Path=Instance.CurrentNiner,Source={StaticResource LocalBindingPoint}}" x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="240"></RowDefinition>
            <RowDefinition Height="60"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <Grid Grid.Row="1" Margin="0,0,0,10" Width="440" Background="{StaticResource PhoneAccentBrush}">
            <Image HorizontalAlignment="Left" Source="Images/achievements.png"></Image>
        </Grid>
        
        <StackPanel x:Name="stkUserPanel" Tap="stkUserPanel_Tap" Orientation="Horizontal">
            <Image Margin="20,0,0,0" Height="200" Width="200" Source="{Binding Avatar}"></Image>
            <StackPanel VerticalAlignment="Center" Margin="20,20,0,20">
                <TextBlock Foreground="Black" Text="{Binding Alias}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeLarge}" TextWrapping="Wrap"></TextBlock>
                <TextBlock Foreground="Gray" Text="{Binding Name}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeMedium}" TextWrapping="Wrap"></TextBlock>
                <TextBlock Foreground="Gray" Text="{Binding Caption}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeMedium}" TextWrapping="Wrap"></TextBlock>
                <TextBlock Foreground="Gray" Text="{Binding Points}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeMedium}" TextWrapping="Wrap"></TextBlock>
            </StackPanel>
        </StackPanel>

        <ListBox Margin="20,20,20,20" Grid.Row="2" ItemsSource="{Binding Achievements}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="0,0,0,30">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Rectangle Fill="{StaticResource PhoneAccentBrush}"></Rectangle>
                        
                        <StackPanel Grid.Column="1" Orientation="Vertical">
                            <Grid>
                                <StackPanel HorizontalAlignment="Left" Margin="20,0,0,0" Orientation="Horizontal">
                                    <Image Height="64" Source="{Binding Icon}"></Image>
                                    <TextBlock FontWeight="Bold" Margin="20,10,0,0" HorizontalAlignment="Center" Text="{Binding Points}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeLarge}" TextWrapping="Wrap" Foreground="Gray"></TextBlock>
                                </StackPanel>
                                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Text="{Binding DateEarned}" TextWrapping="Wrap" Foreground="Black" Style="{StaticResource PhoneTextTitle3Style}"></TextBlock>
                            </Grid>

                            <StackPanel Margin="0,5,0,0">
                                <TextBlock HorizontalAlignment="Left" Text="{Binding FriendlyName}" TextWrapping="Wrap" Foreground="Black"  Style="{StaticResource PhoneTextTitle2Style}"></TextBlock>
                                <StackPanel Margin="0,10,0,0">
                                    <phone:WebBrowser Margin="10,0,0,0" Navigating="WebBrowser_Navigating" Loaded="WebBrowser_Loaded" Height="120" Width="440" local:HtmlStringLoader.HtmlString="{Binding Description}"></phone:WebBrowser>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="btnShare" Click="btnShare_Click" IconUri="/Images/appbar.share.rest.png" Text="share"/>
            <shell:ApplicationBarIconButton x:Name="btnPin" Click="btnPin_Click" IconUri="/Images/appbar.pin.rotated.315.png" Text="pin"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
